import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { PickerController } from '@ionic/angular';

@Component({
  selector: 'app-picker',
  templateUrl: './picker.page.html',
  styleUrls: ['./picker.page.scss'],
})
export class PickerPage implements OnInit {
  like:any = "篮球"

  constructor(public pickerCtrl: PickerController, private router: Router) { }

  ngOnInit() {
  }

  gotohome(){
    this.router.navigate(['/'])
  }

  async openPicker() {
    const picker = await this.pickerCtrl.create({
      animated: false,
      buttons: [{
        text: '确定',
      },{
        text: '取消',
      }],
      columns: [
        {
          name: 'days',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        }
      ]
    });
    await picker.present();
  }

  async openPickera() {
    const picker = await this.pickerCtrl.create({
      backdropDismiss: false,
      buttons: [{
        text: '确定',
      },{
        text: '取消',
      }],
      columns: [
        {
          name: 'days',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        }
      ]
    });
    await picker.present();
  }

  async openPickerb() {
    const picker = await this.pickerCtrl.create({
      buttons: [{
        text: '按钮一',
      },{
        text: '按钮二',
      },{
        text: '按钮三',
      },{
        text: '按钮四',
      }],
      columns: [
        {
          name: 'days',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        }
      ]
    });
    await picker.present();
  }

  async openPickerc() {
    const picker = await this.pickerCtrl.create({
      buttons: [{
        text: '确定',
      },{
        text: '取消',
      }],
      columns: [
        {
          name: 'days',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        },
        {
          name: 'days',
          options: [
            {
              text: '跑步',
              value: 1
            },
            {
              text: '游泳',
              value: 2
            },
            {
              text: '健身',
              value: 3
            },
          ]
        }
      ]
    });
    await picker.present();
  }

  async openPickerd() {
    const picker = await this.pickerCtrl.create({
      mode: "md",
      cssClass: "myPicker",
      buttons: [{
        text: '确定',
      },{
        text: '取消',
      }],
      columns: [
        {
          name: 'days',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        }
      ]
    });
    await picker.present();
  }

  async openPickere() {
    const picker = await this.pickerCtrl.create({
      buttons: [{
        text: '确定',
      },{
        text: '取消',
      }],
      columns: [
        {
          name: 'days',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        }
      ]
    });
    await picker.present();
  }

  async openPickerf() {
    const picker = await this.pickerCtrl.create({
      buttons: [{
        text: '确定',
      },{
        text: '取消',
      }],
      columns: [
        {
          name: 'days',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        }
      ]
    });
    picker.dismiss().then(data=>{console.log("执行dismiss")});
    picker.getColumn(name).then(data=>{console.log("执行getColumn")});
    picker.present().then(data=>{console.log("执行present")});
    picker.onDidDismiss().then(data=>{console.log("执行onDidDismiss")});
    picker.onWillDismiss().then(data=>{console.log("执行onWillDismiss")});
  }

  async openPickerg() {
    const picker = await this.pickerCtrl.create({
      buttons: [{
        text: '确定',
        role: 'destructive',
        handler: (data) => {
           this.like = data.data.text
        }
      },{
        text: '取消',
        role: 'cancel',
        handler: () => {
        }
      }],
      columns: [
        {
          name: 'data',
          options: [
            {
              text: '篮球',
              value: 1
            },
            {
              text: '足球',
              value: 2
            },
            {
              text: '羽毛球',
              value: 3
            },
          ]
        }
      ]
    });
    picker.present();
  }

}
